<%@page import="com.situ.web.vo.StudentBanjiVO"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
	<style type="text/css">
		table{
			border-collapse: collapse;
		}
		td,tr{
			border: 1px black solid;
			width: 200px;
		}
	</style>
</head>
<body>
	<%-- ${list} --%>
	<!-- <a href="/Java202007Web/student_insert.jsp">添加</a> -->
	<a href="/Java202007Web/student?method=getStudentInsertPage">添加</a>
	<form action="<%=request.getContextPath()%>/student?method=selectByName" method="post">
		<input type="text" name="searchName"/>
		<input type="submit" value="搜索"/>
	</form>
	<table border="1" cellspacing="0" width="400px">
		<tr>
			<td>ID</td>
			<td>名字</td>
			<td>年龄</td>
			<td>性别</td>
			<td>班级Id</td>
			<td>班级名字</td>
			<td>删除</td>
			<td>修改</td>
		</tr>
		<% // 这里面可以嵌套java代码
			// 从request里面拿出list数据
			
			List<StudentBanjiVO> list = (ArrayList<StudentBanjiVO>)request.getAttribute("list");
			for (StudentBanjiVO studentBanjiVO : list) {
		%>
				<tr>
					<td><%=studentBanjiVO.getStudentId()%></td>
					<td><%=studentBanjiVO.getStudentName()%></td>
					<td><%=studentBanjiVO.getStudentAge()%></td>
					<td><%=studentBanjiVO.getStudentGender()%></td>
					<td><%=studentBanjiVO.getBanjiId()%></td>
					<td><%=studentBanjiVO.getBanjiName()%></td>
					<%-- <td><a href="/Java202007Web/studentDelete?id=<%=student.getId()%>">删除</a></td> --%>
					<%-- <td><a href="<%=request.getContextPath()%>/student?method=delete&id=<%=student.getId()%>">删除</a></td> --%>
					<td><a href="javascript:void(0)" onclick="deleteById(<%=studentBanjiVO.getStudentId()%>)">删除</a></td>
					<td><a href="<%=request.getContextPath()%>/student?method=selectById&id=<%=studentBanjiVO.getStudentId()%>">修改</a></td>
				</tr>
		<%
			}
		%>
		
		
	</table>
	
	<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/layer/layer.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/mylayer.js" type="text/javascript" charset="utf-8"></script>
	
	<script type="text/javascript">
		$(function() {
			$('tr:first').css('background-color', 'yellow');
			//$('tr:even:not(:first)').css('background-color', 'green');
			$('tr:gt(0):odd').css('background-color', 'green');
		})
		
		function deleteById(id) {
			<%-- 
			var isDelete = confirm('您确认要删除么？');
			if (isDelete) {
				location.href = '<%=request.getContextPath()%>/student?method=delete&id=' + id;
			} --%>
			
			// mylayer.confirm('您确定要删除么?', '${pageContext.request.contextPath}/student?method=delete&id=' + id);
			layer.confirm(
					content,
					{icon : 3},
					function(index){//点击确认触发
						$.post(
							'${pageContext.request.contextPath}/student?method=delete',
							{'id' : id},
							function(jsonObj) {
								
							},
							'json'
						);
						//layer.close(index);
					}
				);
		}
	</script>
</body>
</html>